#ifndef MUTEX_LOCKER_HEADER_H
#define MUTEX_LOCKER_HEADER_H

#define _WIN32_WINNT 0x0501

#include "noncopyable.hpp"
#include <windows.h>

class Mutex : public NonCopyable {

    CRITICAL_SECTION    cs_;

public:
    Mutex()
    {
        ::InitializeCriticalSection(&cs_);
    }

    ~Mutex()
    {
        ::DeleteCriticalSection(&cs_);
    }

    void lock(void)
    {
        ::EnterCriticalSection(&cs_);
    }

    void trylock()
    {
#define _WIN32_WINNT 0x0501
        TryEnterCriticalSection(&cs_);
    }

    void unlock()
    {
        ::LeaveCriticalSection(&cs_);
    }

};


#endif